<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class TweetsAction extends BaseHomeAction {

	public $tid;

//	public function _empty() {
//		$this->tid = ACTION_NAME;
//		$this->index();
//	}
	//显示单条Note
	public function index() {
		$this->init();
		//接收用户点击传过来的tweets_id
		$tid = empty($this->tid) ? (int) $_GET['tweets_id'] : $this->tid;
		$this->assign('tid', $tid);
		$this->assign('school', $this->school);
		$this->display("Tweets_index");
	}

	public function r() {
		$tid = $_GET["tid"];
		$cid = $_GET["cid"];
		if ($tid) {
			$tweets = D("Tweets")->relation("school")->find($tid);
			if ($tweets)
				redirect(C("SITE_URL") . "/" . $tweets["school"]["school_abbr"] . "/tweets/" . $tid);
			else
				$this->error("没有对应的话题");
		}
		if ($cid) {
			$comment = D("Comment")->find($cid);
			if (!$comment)
				$this->error("没有对应的评论");
			$tweets = D("Tweets")->relation("school")->find($comment["tweets_id"]);
			if ($tweets)
				redirect(C("SITE_URL") . "/" . $tweets["school"]["school_abbr"] . "/tweets/" . $comment["tweets_id"] . "#comment-id-" . $cid);
		}
	}

}

?>
